<!DOCTYPE html>

<html lang="en" class="no-js">

<head>
    <meta charset="utf-8"/>
    <title>segs</title>
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta content="width=device-width, initial-scale=1" name="viewport"/>
    <meta content="" name="description"/>
    <meta content="" name="author"/>
    <script src="/vendor/global/jquery.min.js" type="text/javascript"></script>
    <script type="text/javascript" src="/js/bootstrap/js/bootstrap.js"></script>
    <script type="text/javascript" src="/js/bootstrap/js/bootstrapValidator.js"></script>
    <script type="text/javascript" src="/js/moment.js"></script>
    <script type="text/javascript"
            src="/js/jquery.form.js"></script>
    <!-- bootstrap-table.min.js -->
    <script src="/js/bootstrap-table/bootstrap-table.min.js"></script>
    <!-- 引入中文语言包 -->
    <script src="/js/bootstrap-table/bootstrap-table-zh-CN.min.js"></script>
    <link href="/css/bootstrap-table/bootstrap-table.min.css" rel="stylesheet">
    <link rel="stylesheet" href="/layer/mobile/need/layer.css">
    <link rel="stylesheet" href="/js/bootstrap/css/bootstrap.min.css">
    <link rel="stylesheet" href="/css/bootstrap-datetimepicker.css">
    <link rel="stylesheet" href="/css/multiselet-style.css">
    <script type="text/javascript" src="/js/jquery.sselect.js"></script>
    <script type="text/javascript" src="/js/bootstrap-datetimepicker.js"></script>
    <script type="text/javascript" src="/js/locales/bootstrap-datetimepicker.zh-CN.js"></script>
    <script type="text/javascript" src="/js/multiselect.js"></script>
    <script type="text/javascript" src="/layer/layer.js"></script>
    <script type="text/javascript" src="/js/dateformat.js"></script>
    <link href="/vendor/global/simple-line-icons/simple-line-icons.min.css" rel="stylesheet" type="text/css"/>
    <link href="/vendor/global/layout/css/layout.css" rel="stylesheet" type="text/css"/>
    <link href="/vendor/global/layout/css/themes/darkblue.css" rel="stylesheet" type="text/css" id="style_color"/>
    <link href="/vendor/global/components.css" rel="stylesheet" type="text/css"/>

    <link rel="stylesheet" href="/css/index.css">
    <link rel="shortcut icon" href="/favicon.ico"/>
    <style type="text/css">
        .page-footer{display: flex;
            justify-content: center;
            align-items: center;}
        .btn + .btn{margin-left: 0;}
    </style>
</head>

<body class="page-header-fixed page-quick-sidebar-over-content page-sidebar-closed-hide-logo page-container-bg-solid">
<div class="mypage page-header navbar navbar-fixed-top">
    <div class="page-header-inner">
        <div class="page-logo">
            <a href="/cegs/list">
                CEGS
                <!--<img src="/images/login.png" alt="logo" class="logo-default"/>-->
            </a>
            <div class="menu-toggler sidebar-toggler hide">
            </div>
        </div>
        <a href="javascript:;" class="menu-toggler responsive-toggler" data-toggle="collapse" data-target=".navbar-collapse">
        </a>
    </div>
</div>
<div class="clearfix">
</div>
<div class="page-container">
    <div class="page-sidebar-wrapper">
        <div class="page-sidebar navbar-collapse collapse">
            <ul class="page-sidebar-menu " >
                <li class="sidebar-toggler-wrapper">
                    <div class="sidebar-toggler">
                    </div>
                </li>
                <li class="start active open">
                    <a href="javascript:;">
                        <i class="icon-home"></i>
                        <span class="title">数据</span>
                        <span class="selected"></span>
                        <span class="arrow open"></span>
                    </a>
                    <ul class="sub-menu">
                        <li >
                            <a href="/cegs/list">
                                <i class="icon-graph"></i>
                                数据列表</a>
                        </li>
                        <li class="active">
                            <a href="/cegs/index">
                                <i class="icon-bar-chart"></i>
                                数据处理</a>
                        </li>

                    </ul>
                </li>
            </ul>
        </div>
    </div>
    <div class="page-content-wrapper">
        <div class="page-content">
            <form class="form-inline my-layout" enctype="multipart/form-data" id="fromid">
              <div class="row">
                  <div class="form-group ">
                      <label for="doorCode">病区名称</label>
                          <select id="doorCode" class="form-control" name="doorCode">
                              <option value="">请选择</option>
                          </select>
                  </div>
                  <div class="form-group">
                      <label for="deviceNo">设备名称</label>
                          <select id="deviceNo" class="form-control" name="deviceNo">
                              <option value="">请选择</option>
                          </select>
                  </div>
              </div>
              <div class="row">
                  <div class="form-group">
                      <label for="startTime" >开始时间</label>
                          <input type="text" value="" id="startTime" name="startTime" class="form-control" placeholder="请选择开始时间">
                  </div>
                  <div class="form-group">
                      <label for="endTime" >结束时间</label>
                          <input type="text" value="" id="endTime" name="endTime" class="form-control" placeholder="请选择结束时间">
                  </div>
              </div>
              <div class="row">
                  <div class="form-group">
                      <div class="upload-waper">
                          <label for="fileName" >文件上传</label>
                          <a href="#">
                              <input type="file" id="fileName" class="uploadFile" name="fileName" accept="application/vnd.ms-excel,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet">
                          </a>
                          <div class="fileHidden" style="display: none;">
                              <input type="text" id="saveFile" disabled class="form-control">
                          </div>
                      </div>
                  </div>
                  <div class="form-group">
                      <label for="endTime" class="col-sm-2 control-label">&nbsp;</label>
                      <div class="col-md-3">
                          <button type="button" class="btn btn-success" id="uploadFile">上传</button>
                      </div>
                  </div>
              </div>
            </form>

            <div>
                <div class="addwaper">
                    <div class="form-inline addName">
                        <div class="form-group">
                            <label for="expName">名字</label>
                            <input type="text" class="form-control" id="expName" placeholder="请输入名字" name="expName">
                        </div>
                        <button class="btn yellow" id="addName">添加</button>
                            <button class="btn btn-success" id="save">开始比对</button>
                    </div>
                </div>
                <div class="row">
                    <div class="col-xs-3">
                        <select  id="keepRenderingSort" class="form-control" size="8" multiple="multiple" name="from[]">
                        </select>
                    </div>
                    <div class="col-xs-2">
                        <button type="button" id="keepRenderingSort_rightAll" class="btn btn-block">
                            <i  class="glyphicon glyphicon-forward"></i>
                        </button>
                        <button type="button" id="keepRenderingSort_rightSelected" class="btn btn-block">
                            <i class="glyphicon glyphicon-chevron-right"></i>
                        </button>
                        <button type="button" id="keepRenderingSort_leftSelected" class="btn btn-block">
                            <i class="glyphicon glyphicon-chevron-left"></i>
                        </button>
                        <button type="button" id="keepRenderingSort_leftAll" class="btn btn-block">
                            <i class="glyphicon glyphicon-backward"></i>
                        </button>
                    </div>
                    <div class="col-xs-3">
                        <select  id="keepRenderingSort_to" class="form-control" size="8" multiple="multiple" name="to[]"></select>
                    </div>
                </div>
            </div>
        </div>
    </div>

</div>
<div class="page-footer">
    <div class="page-footer-inner">
        2018-cegs
    </div>

</div>

<script src="/vendor/global/bootstrap.min.js" type="text/javascript"></script>
<script src="/vendor/global/scripts/metronic.js" type="text/javascript"></script>
<script src="/vendor/global/layout/scripts/layout.js" type="text/javascript"></script>
<script src="/vendor/global/admin/pages/scripts/index.js" type="text/javascript"></script>
<script>
    jQuery(document).ready(function() {
        Metronic.init(); // init metronic core componets
        Layout.init(); // init layout
        Index.init();
    });
</script>

<script type="text/javascript">
    var date = new Date;
    $('#startTime').val(date.Format("yyyy-MM-dd" + " 01:00"));
    date.setMinutes(date.getMinutes() + 1);
    $('#endTime').val(date.Format("yyyy-MM-dd hh:mm"));
    $('#keepRenderingSort').multiselect({
        search: {
            left: '<input type="text" name="q" class="form-control" placeholder="Search..." />',
            right: '<input type="text" name="q" class="form-control" placeholder="Search..." />',
        },
        fireSearch: function(value) {
            return value.length > 0;
        }
    });
    $("input[name='fileName']").change( function(e) {
        $("#saveFile").val($('#fileName').get(0).files[0].name);
        $(".fileHidden").show();
    });
    $("#addName").click(function () {
    var relname = $("#expName").val();
    if(!relname){
        layer.msg('请填写需要添加的名字！');
        return;
    }
    var arr = [];
    $('#keepRenderingSort_to option').each(function (i) {
        arr[i] = $(this).val();
    });
    if(arr.indexOf(relname)==-1)$("#keepRenderingSort_to").append('<option value="' + relname + '">' + relname + '</option>')
    else layer.msg('已存在该数据！');
    });
    $('#startTime,#endTime').datetimepicker({
        format: 'yyyy-mm-dd hh:ii',
        autoclose: true,
        todayBtn: true,
        language: 'zh-CN',
        minView: 1
    });
    $('#keepRenderingSort').multiselect({
        keepRenderingSort: true
    });
    $("#doorCode").sselect({url: "/cegs/getDoorInfoList"})
    $("#deviceNo").sselect({url: "/cegs/getDeviceInfoList"})

    $('#save').on('click', function (event) {
        var realvalues = [];
        $('#keepRenderingSort_to option').each(function (i) {
            realvalues[i] = $(this).val();
        });
        if(realvalues.length==0){
            layer.msg('请选择可以匹配的数据！');
            return;
        }
        var formData = new FormData($('#fromid')[0]);
        formData.append("excelNames", realvalues.join(","));
        $.ajax({
            url: '/cegs/dataCompare',
            type: 'POST',
            data: formData,
            async: false,
            cache: false,
            contentType: false, //不设置内容类型
            processData: false, //不处理数据
            success: function (data) {
                if(!data.data){
                    layer.msg('没有数据');
                    return ;
                }
                compareResult=data.data;
                layer.open({
                    type: 2,
                    title: '人员名单',
                    maxmin: true,
                    shadeClose: true, //点击遮罩关闭层
                    area: ['800px', '520px'],
                    content: '/cegs/compareResult'
                });
            },
            error: function () {
                alert("上传失败！");
            }
        })
    });
    $('#uploadFile').on('click', function (event) {
        // 如果点击的是右键1
        var doorCode = $("#doorCode").val();
        if(!doorCode){
            layer.msg('请选择病区名称！');
            return;
        }
        var formData = new FormData($('#fromid')[0]);
        var uploadFile = $('#fileName').get(0).files[0];
        if(!uploadFile){
            layer.msg('请选择上传文件！');
            return;
        }
        formData.append("fileName", uploadFile);
        $.ajax({
            url: '/cegs/fileUpload',
            type: 'POST',
            data: formData,
            async: false,
            cache: false,
            contentType: false, //不设置内容类型
            processData: false, //不处理数据
            success: function (data) {
                var h = "";
                $.each(data.data, function (key, value) {//拼接option
                    h += "<option value='" + key + "'>" + value + "</option>";
                })
                $("#keepRenderingSort").append(h)
            },
            error: function () {
                layer.msg('上传失败！');
            }
        })


    })
</script>




</body>
</html>